package com.example.module_house

import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import com.alibaba.android.arouter.facade.annotation.Route
import com.example.lib_common.base.BaseActivity
import com.example.lib_common.utils.ToastUtils
import com.example.module_house.adapter.HouseAdapter
import com.example.module_house.adapter.HouseAdapter1
import com.example.module_house.databinding.ActivityHouseBinding
import com.example.module_house.model.DataConverter
import com.example.module_house.vm.HouseViewModel
import dagger.hilt.android.AndroidEntryPoint
@Route(path = "/house/HouseActivity")
@AndroidEntryPoint
class HouseActivity : BaseActivity<HouseViewModel,ActivityHouseBinding>() {
    override val mLayoutResId: Int
        get() = R.layout.activity_house
    private lateinit var regionAdapter: HouseAdapter1

    private val mViewModel: HouseViewModel by viewModels()

    override fun initView() {
        regionAdapter = HouseAdapter1()
        mBinding.rv1.layoutManager =LinearLayoutManager(this)
        mBinding.rv1.adapter = regionAdapter

        mViewModel.getPatrolList()
    }

    override fun initData() {
        mViewModel.houseListLiveData.observe(this) {
            // 转换数据
            val regionGroups = DataConverter.convertToRegionGroups(it)

            // 提交给Adapter
            regionAdapter.submitList(regionGroups)

        }
    }

}